package top.songxs.gmall.seckill.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import top.songxs.gmall.common.result.Result;
import top.songxs.gmall.seckill.service.SeckillGoodsService;

@RestController
@RequestMapping(value = "/api/activity/seckill/auth")
public class SeckillController {


    @Autowired
    private SeckillGoodsService seckillGoodsService;



    @GetMapping(value = "/getSeckillSkuIdStr/{skuId}")
    public Result<String> getSeckillCode(@PathVariable(value = "skuId") Long skuId) {
        String seckillCode = seckillGoodsService.getSeckillCode(skuId);
        return Result.ok(seckillCode);
    }

    @PostMapping("/seckillOrder/{skuId}")
    public Result seckillOrder(@PathVariable("skuId") Long skuId, @RequestParam("skuIdStr") String skuIdStr){
        // 200： 成功。 代表这个秒杀排队请求成功。 开始秒杀排队
        seckillGoodsService.seckillQueue(skuId,skuIdStr);
        return Result.ok();

    }




}
